﻿<!DOCTYPE html>
<html>
  <!-- Head -->
  <head>
    <title>畜牧源物联平台</title>
    <meta name="keywords" content="畜牧源物联平台" />
    <meta name="description" content="畜牧源物联平台" />
    <!-- Meta-Tags -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <!-- Style -->
    <link rel="stylesheet" type="text/css" th:href="@{/js/plugins/layui-v2.6.8/layui/css/layui.css}">
    <link rel="stylesheet" href="css/login-style.css" type="text/css" media="all" />
    <script>
      if (window.top !== window.self) {
        window.top.location = window.location;
      }
    </script>
  </head>
  <!-- //Head -->

  <!-- Body -->
  <body>
    <div class="centent">
      <div class="main-container">
        <img src="./img/logo.png" class="system-logo" />
        <div class="system-name">
          <h1>畜牧源物联平台</h1>
        </div>
        <form id="login-form" class="login-form">
          <h2>账号密码登录</h2>
          <div class="account-div login-info">
            <span  for="username">账号</span>
            <input id="username" name="username" type="text" placeholder="请输入账号" />
          </div>
          <div class="password-div login-info">
            <span  for="password">密码</span>
            <input id="password" name="password" type="password" placeholder="请输入密码" />
          </div>
          <div id="login-button" class="login-button">登录</div>
          <div class="forget-password-tip">
            <a href="javascript:void(0)">忘记密码?</a>
          </div>
        </form>
      </div>
    </div>
    <div class="copy-name">©2012-2025畜牧源</div>
  </body>
  <!-- //Body -->
  <script th:inline="javascript"> var ctx = [[${#request.getContextPath()}]];</script>
  <script src="js/jquery.min.js?v=2.1.4"></script>
  <script src="js/plugins/layer/layer.min.js" ></script>
  <script type="text/javascript">
    $(document).ready(function () {
      $("#login-button").on('click', function () {
        login();
      });
      $("body").keydown(keyDownLogon);
    });

    function login() {
      if($('#username').val()==''){
        layer.msg('请输入您的账号');
        return;
      }
      if($('#password').val()==''){
        layer.msg('请输入您的密码');
        return;
      }
      $.ajax({
        type: "POST",
        url: ctx + "/login",
        data: $('#login-form').serialize(),
        success: function (r) {
          if (r.code == 0) {
            var index = layer.load(1, {
              shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            parent.location.href = ctx +'/index?from=pc';
          } else {
            layer.msg(r.msg);
          }
        },
      });
    }

    function keyDownLogon() {
      if (event.keyCode == "13") {
        $("#login-button").trigger('click');
      }
    }

  </script>
</html>
